package cn.it.hbbt.untils;



import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateConverter implements Converter<String,Date> {
    private String pattern;

    public DateConverter(String pattern) {
        this.pattern = pattern;
    }

    public Date convert(String source){
        SimpleDateFormat simplDataFormat=new SimpleDateFormat(pattern);
        try {
            return simplDataFormat.parse(source);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}

